package tony.com.test;

import tony.com.xframe.acitivity.BaseActivity;
import tony.com.xframe.widge.CurrentToast;
import tony.com.xframe.widge.TagView;
import tony.com.xframe.widge.tag.Tag;
import tony.com.xframe.widge.tag.TagCloudLinkView;

/**
 * Created by Tony on 2016-01-05.
 */
public class TagViewTestActivity  extends BaseActivity {
    private TagView tagView;
    private String mNames[] = {
            "welcome","android","TextView",
            "apple","jamy","kobe bryant",
            "jordan","layout","viewgroup",
            "margin","padding","text",
            "name","type","search","logcat"
    };
    @Override
    public int getLayoutId() {
        return R.layout.activity_tag;
    }

    @Override
    public void initWidge() {
        initChildViews();
    }

    @Override
    public void widgeClick(int viewId) {

    }

    private void initChildViews() {
        // TODO Auto-generated method stub
//        tagView = (TagView) findViewById(R.id.flowlayout);
//        MarginLayoutParams lp = new MarginLayoutParams(
//                LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
//        lp.leftMargin = 5;
//        lp.rightMargin = 5;
//        lp.topMargin = 5;
//        lp.bottomMargin = 5;
//        for(int i = 0; i < mNames.length; i ++){
//            TextView view = new TextView(this);
//            view.setText(mNames[i]);
//            view.setTextColor(Color.WHITE);
//            view.setBackgroundDrawable(getResources().getDrawable(R.drawable.textview_bg));
//            tagView.addView(view,lp);
//        }

//        TagGroup mTagGroup = (TagGroup) findViewById(R.id.tag_group);
//
//        mTagGroup.setTags(mNames);

        final TagCloudLinkView view = (TagCloudLinkView) findViewById(R.id.tag);
        view.add(new Tag(1,"TAG TEXT 1"));
        view.add(new Tag(1,"TAG TEXT 2"));
        view.add(new Tag(1,"TAG TEXT 3"));
        view.drawTags();
        view.setOnTagSelectListener(new TagCloudLinkView.OnTagSelectListener() {
            @Override
            public void onTagSelected(Tag tag, int position) {
                CurrentToast.getInstance(TagViewTestActivity.this).toastShow(tag.getText());
//                Toast.makeText(TagViewTestActivity.this, tag.getText(), Toast.LENGTH_SHORT).show();

            }
        });
//        mTagGroup.setTags(new String[]{"Tag1", "Tag2", "Tag3"});
    }
}
